package service;

import dao.NavigatorDAOImpl;
import dao.StewardessDAOImpl;
import logic.Navigator;
import logic.Pilot;
import logic.Stewardess;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import java.util.List;
import java.util.Map;

/**
 * Created by Vovancho on 08.12.2014.
 */
@ManagedBean
@ViewScoped
public class StewardessServiceImpl extends Stewardess {

    private StewardessDAOImpl stewardessDAOI = new StewardessDAOImpl();
    private List<Stewardess> stewardesses;

    public List<Stewardess> getStewardesses() {
        return stewardesses;
    }

    public void setStewardesses(List<Stewardess> stewardesses) {
        this.stewardesses = stewardesses;
    }

    public void addStewardess() {
        stewardessDAOI.addStewardess(new Stewardess(getFirstName(), getMiddleName(), getLastName()));
    }

//@PostConstruct
    public List<Stewardess> listStewardess() {
        return stewardessDAOI.listStewardess();
    }

    public  List<Stewardess> stewardessById(int stewardessId){
        return stewardessDAOI.getStewardessById(stewardessId);
    }

    public void removeStewardess() {
        FacesContext context = FacesContext.getCurrentInstance();
        Map<String, String> map = context.getExternalContext().getRequestParameterMap();
        Integer id = new Integer(map.get("stewardessId"));
        stewardessDAOI.removeStewardess(id);
    }
}
